| Fully Qualified Name: | Zend\Hydrator\Strategy\ClosureStrategy |
| Implements: | StrategyInterface |
| Name | Description | Defined By |
|---|---|---|
| __construct() | You can describe how your values will extract and hydrate, like this: | ClosureStrategy |
| extract() | Converts the given value so that it can be extracted by the hydrator. | ClosureStrategy |
| hydrate() | Converts the given value so that it can be hydrated by the hydrator. | ClosureStrategy |
You can describe how your values will extract and hydrate, like this:
$hydrator->addStrategy('category', new ClosureStrategy(
function (Category $value) {
return (int) $value->id;
},
function ($value) {
return new Category((int) $value);
}
));
| Parameter Name | Type | Description |
|---|---|---|
| $extractFunc | callable | - |
| $hydrateFunc | callable | - |
Returns:
Converts the given value so that it can be extracted by the hydrator.
| Parameter Name | Type | Description |
|---|---|---|
| $value | mixed | The |
| $object | array | The |
Returns: mixed Returns the value that should be extracted.
Converts the given value so that it can be hydrated by the hydrator.
| Parameter Name | Type | Description |
|---|---|---|
| $value | mixed | The |
| $data | array | The |
Returns: mixed Returns the value that should be hydrated.